<template>
	<view class="page-my-download">
		<u-navbar title="我的下载" back-icon-color="#000" :border-bottom="false"
		title-size="36" title-color="#000" title-bold></u-navbar>
		 <view class="tab">
		 	<u-tabs :list="tabList" :is-scroll="false" active-color="#c40200" :bar-style="{borderRadius:'5rpx'}"
			inactive-color="#606266" font-size="30" bar-width="113" bar-height="5"
			:current="current" @change="change"></u-tabs>
		 </view>
		<view class="list-warp">
			<view v-if="current == 0">
				<block v-for="(item1,index1) in downList1" :key="item1.id">
					<leftIconRightText :item="item1" @goDetail="goDetail"></leftIconRightText>
				</block>
			</view>
			<view v-if="current == 1">
				<block v-for="(item2,index2) in downList2" :key="item2.id">
					<leftIconRightText :item="item2" @goDetail="goDetail"></leftIconRightText>
				</block>
			</view>
		</view>
	</view>
</template>

<script>
	import {commonGet} from "@/api/commonapi.js"
	import leftIconRightText from '@/components/common/left-icon-right-text.vue'
	export default {
		components:{
			leftIconRightText
		},
		data() {
			return {
				tabList: [{
					name: '图集规范'
				}, {
					name: '执业培训'
				}],
				current: 0,
				downList1:[],
				downList2:[],
				sysMemID:"",
				pagesize:10
			}
		},
		onLoad(options) {
			if(this.$store.state.userIn){
				this.sysMemID = this.$store.state.userIn.id
			}
			this.getDownList()
		},
		methods: {
			change(index) {
				this.current = index;
			},
			getDownList(pagesize){
				let _this = this
				let query = {
					ak:_this.$store.state.token,
					cmd:"mydowns_list_proc",
					para:JSON.stringify({
						sysMemID:_this.sysMemID
					})
				}
				commonGet(query,({Data})=>{
					_this.downList1 = Data.Datas1
					_this.downList2 = Data.Data
				})
			},
			goDetail(item){
				if(this.current == 0){
					this.$u.route('/pages/HomeLnner/AtlasDetails/AtlasDetails', {id: item.newid});
				}else{
					this.$u.route('/pages/HomeLnner/PracticeDetails/PracticeDetails', {id: item.newid});
				}
			}
		},
		onPullDownRefresh() {
			this.pagesize = 10
			this.getDownList(this.pagesize)
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			this.pagesize += 10
			this.getDownList(this.pagesize)
		},
	}
</script>

<style lang="scss" scoped>
.list-warp{
	padding: 0 30rpx;
}
.tab{
	border-bottom: 1px solid #f0f0f0;
}
	
</style>
